#include "Framework/Prerequisites.h"
#include "Math/Math.h"
#include "Math/Matrix4.h"
#include "Math/Quaternion.h"
#include "Math/Vector3.h"

namespace tyro
{

	namespace Math
	{


		

		Matrix4f CreateViewMatrix( const Vector3f& position, const Quaternionf& orientation, const Matrix4f* reflectMatrix /*= 0 */ )
		{

			Matrix3f rotationMatrix;
			Matrix3f rotationTranspose;
			orientation.ToRotationMatix(rotationMatrix);
			rotationMatrix.GetTranspose(rotationTranspose);

			Vector3f translation = -rotationTranspose * position;

			Matrix4f viewMatrix = Matrix4f::IDENTITY;

			viewMatrix = rotationTranspose;
			viewMatrix.m03 = translation.x;
			viewMatrix.m13 = translation.y;
			viewMatrix.m23 = translation.z;

			if (reflectMatrix)
			{
				viewMatrix = viewMatrix * (*reflectMatrix);
			}

			return viewMatrix;
		}

		

	}
}